<?php

namespace app\admin\controller;

use think\facade\App;

class Order extends Base {

    /**
     * @desc 商品订单
     */
    public function goodsOrder() {
        $params['userName']  = input('userName', '', 'trim');
        $params['orderNo']   = input('orderNo');
        $params['goodsName'] = input('goodsName');

        $logic = App::model('Order', 'logic');
        $data = $logic->goodsOrder($params);

        $this->assign($data);
        return view();
    }
    
    /**
     * @desc 充值订单
     */
    public function rechargeOrder() {
        $params['userName']    = input('userName', '', 'trim');
        $params['orderNo']     = input('orderNo');
        $params['accountName'] = input('accountName');
        
        $logic = App::model('Order', 'logic');
        $data = $logic->rechargeOrder($params);
        
        $this->assign($data);
        return view();
    }
    
    /**
     * @desc 订单锁定
     */
    public function locking() {
        $params['id']       = input('id');
        $params['memberId'] = $this->memberId;
        
        $logic = model('Order', 'logic');
        $data = [];
        try {
            $data = $logic->locking($params, $this->memberInfo);
        } catch (\Exception $e) {
            $logic->errorCode = EC_FAILURE;
            $logic->message = $e->getMessage();
        }
        return send_response($data, $logic->errorCode, $logic->message);
    }
    
    
    /**
     * @desc 订单订单
     */
    public function confirm() {
        $params['id']       = input('id');
        $params['memberId'] = $this->memberId;
        
        $logic = model('Order', 'logic');
        $data = [];
        try {
            $data = $logic->confirm($params, $this->memberInfo);
        } catch (\Exception $e) {
            $logic->errorCode = EC_FAILURE;
            $logic->message = $e->getMessage();
        }
        return send_response($data, $logic->errorCode, $logic->message);
    }
    
    /**
     * @desc 拒绝订单
     */
    public function refuse() {
        $params['id']     = input('id');
        $params['memberId'] = $this->memberId;
        
        $logic = model('Order', 'logic');
        $data = [];
        try {
            $data = $logic->refuse($params, $this->memberInfo);
        } catch (\Exception $e) {
            $logic->errorCode = EC_FAILURE;
            $logic->message = $e->getMessage();
        }
        return send_response($data, $logic->errorCode, $logic->message);
    }
}
